package com.bonc.rms.utils;

import java.net.UnknownHostException;

import com.bonc.odk.es.search.ISearchService;
import com.bonc.odk.es.search.impl.SearchServiceImpl;
import com.bonc.odk.logmanager.LogManager;
import com.bonc.rms.config.Config;



public class ESManager {

	private static ESManager instance = null;

	private ISearchService searchService;

	private ESManager() {
		try {
			searchService = new SearchServiceImpl(
					Config.ELASTICSEARCH_IP,
					Config.ELASTICSEARCH_PORT,
					Config.ELASTICSEARCH_NAME);

		} catch (UnknownHostException e) {
			LogManager.Exception(e);
		}
	}

	public static synchronized ESManager getInstance() {
		if (instance == null) {
			instance = new ESManager();
		}
		return instance;
	}

	public ISearchService getSearchService() {
		return searchService;
	}

	public void searchClose() {
		searchService.close();
	}

}

